package lowijs.XfireClient;

import java.util.*;
import lowijs.XfireClient.packet.*;

public class Conversation {
	private final ArrayList<IM> ims =
		new ArrayList<IM>();
	private Friend f;
	private int imindex = 1;
		
	public Conversation(Friend f) {
		this.f = f;
	}
	
	public ArrayList<IM> getMessages() {
		return ims;
	}
	
	public Friend getFriend() {
		return f;
	}
	
	public void receiveIM(IM im) {
		ims.add(im);
		imindex++;
	}
	
	public void sendIM(String message) {
		XfireClient xfc = XfireClient.getInstance();
		IM im = new IM(xfc.getNickname(), message);
		SendImPacket sip = new SendImPacket(f.getSid(), imindex, message);
		xfc.sendPacket(sip);
		ims.add(im);
		imindex++;
	}
}
